package com.ruoyi.web.controller.barcode;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BarcodeUser;
import com.ruoyi.system.service.IBarcodeUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 条码用户Controller
 * 
 * @author ruoyi
 * @date 2025-03-28
 */
@RestController
@RequestMapping("/barcode/user")
public class BarcodeUserController extends BaseController
{
    @Autowired
    private IBarcodeUserService barcodeUserService;

    /**
     * 查询条码用户列表
     */
    @PreAuthorize("@ss.hasPermi('barcode:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(BarcodeUser barcodeUser)
    {
        startPage();
        List<BarcodeUser> list = barcodeUserService.selectBarcodeUserList(barcodeUser);
        return getDataTable(list);
    }

    /**
     * 导出条码用户列表
     */
    @PreAuthorize("@ss.hasPermi('barcode:user:export')")
    @Log(title = "条码用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BarcodeUser barcodeUser)
    {
        List<BarcodeUser> list = barcodeUserService.selectBarcodeUserList(barcodeUser);
        ExcelUtil<BarcodeUser> util = new ExcelUtil<BarcodeUser>(BarcodeUser.class);
        util.exportExcel(response, list, "条码用户数据");
    }

    /**
     * 获取条码用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('barcode:user:query')")
    @GetMapping(value = "/{employeeId}")
    public AjaxResult getInfo(@PathVariable("employeeId") String employeeId)
    {
        return success(barcodeUserService.selectBarcodeUserByEmployeeId(employeeId));
    }

    /**
     * 新增条码用户
     */
    @PreAuthorize("@ss.hasPermi('barcode:user:add')")
    @Log(title = "条码用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BarcodeUser barcodeUser)
    {
        return toAjax(barcodeUserService.insertBarcodeUser(barcodeUser));
    }

    /**
     * 修改条码用户
     */
    @PreAuthorize("@ss.hasPermi('barcode:user:edit')")
    @Log(title = "条码用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BarcodeUser barcodeUser)
    {
        return toAjax(barcodeUserService.updateBarcodeUser(barcodeUser));
    }

    /**
     * 删除条码用户
     */
    @PreAuthorize("@ss.hasPermi('barcode:user:remove')")
    @Log(title = "条码用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{employeeIds}")
    public AjaxResult remove(@PathVariable String[] employeeIds)
    {
        return toAjax(barcodeUserService.deleteBarcodeUserByEmployeeIds(employeeIds));
    }
}
